<template>
	<div class="wrapper">

		<!-- header部分 -->
		<header>
			<i class="fa fa-arrow-circle-left" @click="back()">返回</i>
			<p>店铺管理</p>
		</header>

		<!-- 地址列表部分 -->
		<ul class="addresslist">
			<li>
				<div class="addresslist-left" @click="toBusinessmanage()">
					<img :src="business.businessImg">
					<div class="food-left-info">
						<h3>{{business.businessName}}</h3>
						<p>{{business.businessExplain}}</p>
					</div>
				</div>
				<div class="addresslist-right">
					<i class="fa fa-edit" @click="toAddGoods()"></i>
					<i class="fa fa-remove" ></i>
				</div>
			</li>
		</ul>

		<!-- 新增地址部分 -->
		<div class="addbtn" @click="toAddGoods">
			<i class="fa fa-plus-circle"></i>
			<p>新增店铺</p>
		</div>

		<!-- 底部菜单部分 -->
		<Footer></Footer>
	</div>
</template>

<script>
	import Footer from '../components/Footer.vue';

	export default {
		name: 'GoodsManage',
		data() {
			return {
				businessId: this.$route.query.businessId,
				business: {},
				foodArr: [],
				user: {}
				
			}
		},
		created() {
			this.user = this.$getSessionStorage('user');
			//根据businessId查询商家信息
			this.$axios.post('BusinessController/getBusinessByOwnerId', this.$qs.stringify({
				ownerUserId: this.user.userId
			})).then(response => {
				console.log('Response Data:', response.data);
				this.business = response.data;
				console.log('Response Data:', this.business);
			}).catch(error => {
				console.error(error);
			});

			//根据businessId查询所属食品信息
			this.$axios.post('FoodController/listFoodByBusinessId', this.$qs.stringify({
				businessId: this.businessId
			})).then(response => {
				this.foodArr = response.data;
				
			}).catch(error => {
				console.error(error);
			});
		},
		methods: {
			back() {
				window.history.back(); // 使用浏览器的回退功能返回上一页
			},
			toBusinessmanage(){
				this.$router.push({
					path: '/businessManage',
					query: {
						businessId: this.businessId
					}
				});
			},
			toOrder() {
				this.$router.push({
					path: '/orders',
					query: {
						businessId: this.businessId
					}
				});
			},
			toAddGoods() {
				this.$router.push({
					path: '/addGoods',
					query: {
						businessId: this.businessId
					}
				});
			},
			editGoods(daId) {
				this.$router.push({
					path: '/editGoods',
					query: {
						businessId: this.businessId,
						daId: daId
					}
				});
			}
			
		},
		components: {
			Footer
		}
	}
</script>
<style scoped>
	/*************** 总容器 ***************/
	.wrapper {
		width: 100%;
		height: 100%;
		background-color: #F5F5F5;
	}

	/*************** header ***************/
	.wrapper header {
		width: 100%;
		height: 12vw;
		background-color: #0097FF;
		display: flex;
		justify-content: space-around;
		align-items: center;
		color: #fff;
		font-size: 4.8vw;
		position: fixed;
		left: 0;
		top: 0;
		/*保证在最上层*/
		z-index: 1000;
	}
	.wrapper header i{
	color: #fff;
	font-size: 3vw;
    position: absolute;
	left: 0;
	text-align: left;
	cursor: pointer;
	
}
	/*************** addresslist ***************/
	.wrapper .addresslist {
		width: 100%;
		margin-top: 12vw;
		background-color: #fff;
	}

	.wrapper .addresslist li {
		width: 100%;
		box-sizing: border-box;
		border-bottom: solid 1px #DDD;
		padding: 3vw;

		display: flex;
	}

	.wrapper .addresslist li .addresslist-left {
		display: flex;
		align-items: center;
		position: relative;
	}
	.wrapper .addresslist li .addresslist-left  img{
		width: 20vw;
		height: 20vw;
	}
	.wrapper .addresslist li .addresslist-left .food-left-info h3 {
		font-size: 4.6vw;
		font-weight: 300;
		color: #666;
	}

	.wrapper .addresslist li .addresslist-left .food-left-info p {
		font-size: 4vw;
		color: #666;
	}

	.wrapper .addresslist li .addresslist-right {
		flex: 1;
		font-size: 5.6vw;
		color: #999;
		cursor: pointer;

		display: flex;
		justify-content: space-around;
		align-items: center;
	}
	

	/*************** 新增地址部分 ***************/
	.wrapper .addbtn {
		width: 100%;
		height: 14vw;
		border-top: solid 1px #DDD;
		border-bottom: solid 1px #DDD;
		background-color: #fff;
		margin-top: 4vw;

		display: flex;
		justify-content: center;
		align-items: center;

		font-size: 4.5vw;
		color: #0097FF;
		user-select: none;
		cursor: pointer;
	}

	.wrapper .addbtn p {
		margin-left: 2vw;
	}
</style>
